<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">

		<style>
			#star {
				color: red;
			}
		</style>
	</head>

	<body style="padding:0px;background-color: white">
		<div id="toolbar" class="receipts_toolbar_style">
		</div>
		<div>
			<form id="ff" action="#" method="post">
				<table cellpadding="5" class="displaytable" style="text-align: left;width: 80%;margin: 0 auto;">
					<tr>
						<td width="10%">
							<h id="star">* </h>配送时间</td>
						<td width="25%">
							<input type="text" id="input_DISTRIBUTION_DATE" class="easyui-datebox" name="DISTRIBUTION_DATE" data-options="prompt:'请输入配送时间',required:'true'" />
						</td>
						<td width="10%">
							<h id="star">* </h>配送员</td>
						<td width="25%">
							<input type="text" id="input_DELIVERY_MAN" class="easyui-textbox" name="DELIVERY_MAN" data-options="prompt:'请输入配送员名称',required:'true'" />
						</td>
						<td width="10%">
							<h id="star">* </h>配送方式</td>
						<td width="25%">
							<input type="combobox" id="input_DELIVERY_METHOD" class="easyui-combobox" name="DELIVERY_METHOD" data-options="prompt:'请输入配送方式',required:'true'" />
							<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="AddDELIVERY_METHODName()"></a>
						</td>
					</tr>
					<tr>

						<td>
							<h id="star">* </h>车牌号</td>
						<td>
							<input type="text" id="input_CAR_NO" class="easyui-textbox" name="CAR_NO" data-options="prompt:'请输入配送车辆车牌号',required:'true'" />
						</td>
						<td>
							<h id="star">* </h>租车费用</td>
						<td>
							<input type="text" id="input_RENT_COST" class="easyui-numberbox" name="RENT_COST" precision="2" />
						</td>
						<td>
							<h id="star">* </h>装卸费用</td>
						<td>
							<input type="text" id="input_HANDING_COST" class="easyui-numberbox" name="HANDING_COST" precision="2" />
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>油费</td>
						<td>
							<input type="text" id="input_OIL_COST" class="easyui-numberbox" name="OIL_COST" precision="2" />
						</td>
						<td>
							<h id="star">* </h>其他费用</td>
						<td>
							<input type="text" id="input_OTHER_COST" class="easyui-numberbox" name="OTHER_COST" precision="2" />
						</td>
						<td>
							<h id="star">* </h>费用总计</td>
						<td>
							<input type="text" id="input_LUMP_SUM" class="easyui-numberbox" name="LUMP_SUM" precision="2" data-options="disabled:true" />
						</td>
					</tr>

				</table>
				<div id="tt"></div>
				<div style="margin-left: 20%;" id="new_footer">

				</div>
			</form>
		</div>
		<div id="listtoolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src="../../../JS/finance.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.edatagrid.js"></script>
	<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
	<script type="text/javascript" src="../../../JS/LogisticsShareFunction/CommonShareFunction.js"></script>
	<script type="text/javascript" src="../../../JS/LogisticsShareFunction/DeliverShareFunction.js"></script>

	<script type="text/javascript">
		var currDetailData;

		iniDeliverMethod(); //初始化配送方式
		getRemoteData();
		GetTable();
		var data = [{
			"icon": "icon-redo",
			"func": "ProcessOrder()",
			"functionname": "生成配送单"
		}];
		content = AddReceiptsToolBar(0, data);
		$("#toolbar").append(content);

		function ProcessOrder() {
			getData();
		}

		function searchmore() {
			AddTabIn("配送订单查询", parent.$('#tabs'), "UI/LOGISTICS/DeliverManagement/DeliverManagementSearch.html");
		}

		function getRemoteData() //统一获取远程的数据
		{
			var _localData = localStorage.getItem('DeliverSelectData');
			if(_localData != null) {
				currDetailData = JSON.parse(_localData);
			} else {
				$.messager.alert("错误", "没有选中的数据");
			}

		}

		function GetTable() { //构造datagrid中的数据
			$('#tt').datagrid({
				data: currDetailData,
				method: 'get',
				pagination: 'true',
				rownumbers: 'true',
				autoRowHeight: 'true',
				fitColumns: 'false',
				height: 350,
				/*表格中的列名以及各自列名的ID*/
				columns: [
					[{
						field: 'ID',
						title: '编号',
						width: '10%',
						align: 'center'
					}, {
						field: 'CUSTOMER_TYPE',
						title: '用户组',
						width: '24%',
						align: 'center'
					}, {
						field: 'CUSTOMER_NAME',
						title: '配送单位',
						width: '31%',
						align: 'center'
					}, {
						field: 'DISTRIBUTION_DATE',
						title: '配送时间',
						width: '32%',
						align: 'center'
					}]
				],
			});
		}

		function submitData(_data) {
			_url = RemoteLinkAddress + "/logistics/deliverorder/save.do";
			////////////////////////////////////////////
			var _senddata = JSON.stringify(_data);
			$.ajax({
				dataType: 'JSON',
				url: _url,
				data: 'a=' + _senddata,
				type: "POST",
				success: function(result) {
					$.messager.alert({
						title: '成功',
						msg: '保存成功',
						fn: function() {

							parent.$('#tabs').tabs('close', "创建配送单");

						}
					});
					localStorage.removeItem('DeliverSelectData');
					return;
					/////////////////////////////
				},
				error: function(result) {
					$.messager.alert("错误", "保存不成功");
				}
			});
		}

		function getData() {
			var _data = submitFormData();
			_data.LUMP_SUM = CalDeliverCost(_data);
			$("#input_LUMP_SUM").textbox('setValue', _data.LUMP_SUM);
			var dataGridRows = $("#tt").datagrid("getRows");
			var _index = 0;
			_data.rows = new Array();
			for(var i = 0; i < dataGridRows.length; i++) {
				_data.rows[_index] = new Object();
				_data.rows[_index].SALESORDER_ID = dataGridRows[i].ID;
				_index = _index + 1;
			}
			submitData(_data);
		}
	</script>

</html>